import sys
import time

from xmlrpclib import ServerProxy

CONFIG_FILENAME = "servers.conf"

def doLog(msg):
	print "[%s] %s" %(time.ctime(), msg)

def main():
	f = file(CONFIG_FILENAME, "r").readlines()
	for line in f:
		url = line.strip("\r").strip("\n")

	if url == "" or url.startswith("#"):
		continue

		s = ServerProxy(url)
		
		try:
			status = s.ping()
			doLog("Status of server %s is %s" % (url, status))
		except:
			doLog("Server %s is down: %s" % (url, sys.exc_info()[1]))

def usage():
	print "Usage:", sys.argv[0]
	print

if __name__ == "__main__":
	main()

